package com.ibeeking.found.content.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.content.b.rest.service.IBroadcastGroupService;
import com.ibeeking.found.content.service.common.param.BroadcastGroupParam;
import com.ibeeking.found.content.service.common.query.BroadcastGroupPageQuery;
import com.ibeeking.found.content.service.common.query.BroadcastGroupQuery;
import com.ibeeking.found.content.service.common.vo.BroadcastGroupVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BroadcastController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-02-18 14:11
 **/
@RestController
@RequestMapping("/b/broadcast/v1/group")
public class BroadcastGroupController {

    @Resource
    private IBroadcastGroupService broadcastGroupServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播分组列表")
    @PostMapping(value = "/list")
    public List<BroadcastGroupVO> groupList(@RequestBody BroadcastGroupQuery query) {
        return broadcastGroupServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播分组分页列表")
    @PostMapping(value = "/pageList")
    public Page<BroadcastGroupVO> groupPageList(@RequestBody BroadcastGroupPageQuery pageQuery) {
        return broadcastGroupServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "直播分组添加")
    @PostMapping(value = "/add")
    public Boolean groupAdd(@RequestBody @Validated BroadcastGroupParam param) {
        return broadcastGroupServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "直播分组修改")
    @PostMapping(value = "/modify")
    public Boolean groupModify(@RequestBody @Validated BroadcastGroupParam param) {
        return broadcastGroupServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播分组查看")
    @GetMapping(value = "/view/{id}")
    public BroadcastGroupVO groupView(@PathVariable("id") Long id) {
        return broadcastGroupServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "直播分组删除")
    @GetMapping(value = "/del/{id}")
    public Boolean groupDel(@PathVariable("id") Long id) {
        return broadcastGroupServiceImpl.del(id);
    }

}
